#line 1 "/Users/Home/Documents/Workspace/IOS_reverse/WeChatRedbag/WeChatRedbag/RedBagAuto.xm"
#import <UIKit/UIKit.h>
#import "MRedBagHead.h"
#import "HongBaoQueue.h"


#include <substrate.h>
#if defined(__clang__)
#if __has_feature(objc_arc)
#define _LOGOS_SELF_TYPE_NORMAL __unsafe_unretained
#define _LOGOS_SELF_TYPE_INIT __attribute__((ns_consumed))
#define _LOGOS_SELF_CONST const
#define _LOGOS_RETURN_RETAINED __attribute__((ns_returns_retained))
#else
#define _LOGOS_SELF_TYPE_NORMAL
#define _LOGOS_SELF_TYPE_INIT
#define _LOGOS_SELF_CONST
#define _LOGOS_RETURN_RETAINED
#endif
#else
#define _LOGOS_SELF_TYPE_NORMAL
#define _LOGOS_SELF_TYPE_INIT
#define _LOGOS_SELF_CONST
#define _LOGOS_RETURN_RETAINED
#endif

@class CContactMgr; @class MMContext; @class WCRedEnvelopesLogicMgr; @class WCBizUtil; @class CMessageMgr; 
static void (*_logos_orig$_ungrouped$WCRedEnvelopesLogicMgr$OnWCToHongbaoCommonResponse$Request$)(_LOGOS_SELF_TYPE_NORMAL WCRedEnvelopesLogicMgr* _LOGOS_SELF_CONST, SEL, HongBaoRes*, HongBaoReq*); static void _logos_method$_ungrouped$WCRedEnvelopesLogicMgr$OnWCToHongbaoCommonResponse$Request$(_LOGOS_SELF_TYPE_NORMAL WCRedEnvelopesLogicMgr* _LOGOS_SELF_CONST, SEL, HongBaoRes*, HongBaoReq*); static void (*_logos_orig$_ungrouped$CMessageMgr$onNewSyncAddMessage$)(_LOGOS_SELF_TYPE_NORMAL CMessageMgr* _LOGOS_SELF_CONST, SEL, CMessageWrap*); static void _logos_method$_ungrouped$CMessageMgr$onNewSyncAddMessage$(_LOGOS_SELF_TYPE_NORMAL CMessageMgr* _LOGOS_SELF_CONST, SEL, CMessageWrap*); 
static __inline__ __attribute__((always_inline)) __attribute__((unused)) Class _logos_static_class_lookup$WCBizUtil(void) { static Class _klass; if(!_klass) { _klass = objc_getClass("WCBizUtil"); } return _klass; }static __inline__ __attribute__((always_inline)) __attribute__((unused)) Class _logos_static_class_lookup$WCRedEnvelopesLogicMgr(void) { static Class _klass; if(!_klass) { _klass = objc_getClass("WCRedEnvelopesLogicMgr"); } return _klass; }static __inline__ __attribute__((always_inline)) __attribute__((unused)) Class _logos_static_class_lookup$CContactMgr(void) { static Class _klass; if(!_klass) { _klass = objc_getClass("CContactMgr"); } return _klass; }static __inline__ __attribute__((always_inline)) __attribute__((unused)) Class _logos_static_class_lookup$MMContext(void) { static Class _klass; if(!_klass) { _klass = objc_getClass("MMContext"); } return _klass; }
#line 5 "/Users/Home/Documents/Workspace/IOS_reverse/WeChatRedbag/WeChatRedbag/RedBagAuto.xm"

static void _logos_method$_ungrouped$WCRedEnvelopesLogicMgr$OnWCToHongbaoCommonResponse$Request$(_LOGOS_SELF_TYPE_NORMAL WCRedEnvelopesLogicMgr* _LOGOS_SELF_CONST __unused self, SEL __unused _cmd, HongBaoRes* arg1, HongBaoReq* arg2){
 
    NSLog(@"SKBuiltinBuffer_t：%@",[[NSString alloc] initWithData:arg1.retText.buffer encoding:NSUTF8StringEncoding]);
   NSError *err;
   NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:arg1.retText.buffer options:NSJSONReadingMutableContainers error:&err];
    
    if(dic!=nil&&[[dic objectForKey:@"hbType"] intValue]==1&&[[dic objectForKey:@"hbStatus"] intValue]==2){
  
        NSMutableDictionary* mudic= [[HongBaoQueue shareQueue] getFromQueue];
        if(mudic!=nil){
            [mudic setObject:[dic objectForKey:@"timingIdentifier"] forKey:@"timingIdentifier"];
            
            
            float time=0;
            if([GYUserDefault valueForKey:GYTIMEKEY]&&[[GYUserDefault valueForKey:GYTIMEKEY] length]>0){
                time=[[GYUserDefault valueForKey:GYTIMEKEY] floatValue];
            }
            dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(time * NSEC_PER_SEC)), dispatch_get_global_queue(0, 0), ^{
                WCRedEnvelopesLogicMgr* logicmgr= [[_logos_static_class_lookup$MMContext() currentContext] getService:[_logos_static_class_lookup$WCRedEnvelopesLogicMgr() class]];
                [logicmgr OpenRedEnvelopesRequest:mudic];
            });
            
           
        }
    }
    
        
    
    _logos_orig$_ungrouped$WCRedEnvelopesLogicMgr$OnWCToHongbaoCommonResponse$Request$(self, _cmd, arg1, arg2);
}




static void _logos_method$_ungrouped$CMessageMgr$onNewSyncAddMessage$(_LOGOS_SELF_TYPE_NORMAL CMessageMgr* _LOGOS_SELF_CONST __unused self, SEL __unused _cmd, CMessageWrap* msgwrap) {
    NSLog(@"收到消息：%@",msgwrap);
    if(msgwrap.m_uiMessageType==49&&[msgwrap.m_oWCPayInfoItem.m_c2cNativeUrl containsString:@"wxpay://c2cbizmessagehandler/hongbao/receivehongbao?"]&&[GYUserDefault boolForKey:GYSWITCHKEY]){
        NSLog(@"收到红包消息并且打开开关%@", [GYUserDefault valueForKey:GYTIMEKEY]);
        if([GYUserDefault valueForKey:GYTIMEKEY]){
            NSLog(@"存在时间%@",[GYUserDefault valueForKey:GYTIMEKEY]);
        }

 
        
        NSString* m_c2cNativeUrl=msgwrap.m_oWCPayInfoItem.m_c2cNativeUrl;
        long length=[@"wxpay://c2cbizmessagehandler/hongbao/receivehongbao?" length];
        NSString* sub_nativeUrl= [m_c2cNativeUrl substringFromIndex:length];

        NSMutableDictionary* mudic15=[_logos_static_class_lookup$WCBizUtil() dictionaryWithDecodedComponets:sub_nativeUrl separator:@"&"];
        NSMutableDictionary* mudic=[NSMutableDictionary dictionary];
        [mudic setObject:@"1" forKey:@"msgType"];
        [mudic setObject:[mudic15 objectForKey:@"sendid"] forKey:@"sendId"];
        [mudic setObject:[mudic15 objectForKey:@"channelid"] forKey:@"channelId"];

        CContactMgr* conmgr=[[_logos_static_class_lookup$MMContext() currentContext] getService:[_logos_static_class_lookup$CContactMgr() class]];

         CContact* contact=[conmgr getSelfContact];

         [mudic setObject:[contact getContactDisplayName] forKey:@"nickName"];
         [mudic setObject:contact.m_nsHeadImgUrl forKey:@"headImg"];
    

        if (msgwrap)
        {
            WCPayInfoItem* infoitem=msgwrap.m_oWCPayInfoItem;
            NSString* c2nativeurl=infoitem.m_c2cNativeUrl;
            [mudic setObject:c2nativeurl forKey:@"nativeUrl"];
        }
        [mudic setObject:msgwrap.m_nsFromUsr forKey:@"sessionUserName"];
        NSLog(@"已构造的参数：%@",mudic);
        
        [[HongBaoQueue shareQueue] AddToQueue:mudic];
        
       
       NSMutableDictionary* param=[NSMutableDictionary dictionary];
       [param setObject:@"0" forKey:@"agreeDuty"];
        [param setObject:mudic[@"channelId"] forKey:@"channelId"];
        [param setObject:@"1" forKey:@"inWay"];
        [param setObject:mudic[@"msgType"] forKey:@"msgType"];
        [param setObject:mudic[@"nativeUrl"] forKey:@"nativeUrl"];
        [param setObject:mudic[@"sendId"] forKey:@"sendId"];
        
        WCRedEnvelopesLogicMgr* logicmgr= [[_logos_static_class_lookup$MMContext() currentContext] getService:[_logos_static_class_lookup$WCRedEnvelopesLogicMgr() class]];
        [logicmgr ReceiverQueryRedEnvelopesRequest:param];

    }else{
        _logos_orig$_ungrouped$CMessageMgr$onNewSyncAddMessage$(self, _cmd, msgwrap);
    }

    _logos_orig$_ungrouped$CMessageMgr$onNewSyncAddMessage$(self, _cmd, msgwrap);
    
  
}






























    
    


































































    




















static __attribute__((constructor)) void _logosLocalInit() {
{Class _logos_class$_ungrouped$WCRedEnvelopesLogicMgr = objc_getClass("WCRedEnvelopesLogicMgr"); { MSHookMessageEx(_logos_class$_ungrouped$WCRedEnvelopesLogicMgr, @selector(OnWCToHongbaoCommonResponse:Request:), (IMP)&_logos_method$_ungrouped$WCRedEnvelopesLogicMgr$OnWCToHongbaoCommonResponse$Request$, (IMP*)&_logos_orig$_ungrouped$WCRedEnvelopesLogicMgr$OnWCToHongbaoCommonResponse$Request$);}Class _logos_class$_ungrouped$CMessageMgr = objc_getClass("CMessageMgr"); { MSHookMessageEx(_logos_class$_ungrouped$CMessageMgr, @selector(onNewSyncAddMessage:), (IMP)&_logos_method$_ungrouped$CMessageMgr$onNewSyncAddMessage$, (IMP*)&_logos_orig$_ungrouped$CMessageMgr$onNewSyncAddMessage$);}} }
#line 218 "/Users/Home/Documents/Workspace/IOS_reverse/WeChatRedbag/WeChatRedbag/RedBagAuto.xm"
